﻿// JavaScript Document
function $(objname){ return document.getElementById(objname);}
var request = { 
QueryString : function(val) { 
var uri = window.location.search; 
var re = new RegExp("" +val+ "=([^&?]*)", "ig"); 
return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null); 
}} 
function searchgo()
{  
    var a = document.getElementById("keyword");
    var b = document.getElementById("search_tab");
    var link; 
    if( b.value ==10)
    { 
        link = "http://zixun.58.com/plus/search1.php?search_tab=1&kwtype=0&keyword="+a.value; 
    }
    else
    {
        link= "/"+b.value+"/?key="+encodeURI(a.value);
    }
    window.location= link;
    return true;
}
function SearchStatic(key, url) {
    try {
        if (document.frames) {
            document.frames['tooltipcontentframe'].SearchStaticKey(key, url);
        }
        else {
            document.getElementById('tooltipcontentframe').SearchStaticKey(key, url);
        }
    } catch (e) { }
} 
function searchList()
{
	var cc = document.getElementById("keyword").value;
	if(cc ==""||cc=="请输入类别名称或关键字")
	{window.location.href="/";}
	else {
	    window.location.href = "/sou/?key=" + encodeURI(document.getElementById("keyword").value) + "&jump=1";
	    try {
	        SearchStatic(document.getElementById("keyword").value, 'http://' + window.location.host + "/sou/?key=" + encodeURI(document.getElementById("keyword").value) + "&jump=1");
	    } catch (ex) { }
	}
}			 
function keysearch(evt)
{
    var k=window.event?evt.keyCode:evt.which;
	if(k==13){ window.location.href="/sou/?key="+encodeURI(document.getElementById("keyword").value)+"&jump=1";}
}

//bcity_ad_tou
var notestr='';

function InitNote()
{
    if(notestr=='') return;
    else
    {
        var startStr = '<div id="show_notice">';
        var endStr ='<div class="ico_close" onclick="$(\'show_notice\').style.display=\'none\'"></div></div>';
        document.write(startStr+notestr+endStr);
    }
}

function settopswitchtab(input)
{
	return;	
}


function GetCookies(name)
{   
	var arr = document.cookie.match(new RegExp(name+"=([^&;]+)"));
	if(arr != null){return decodeURI(arr[1]);} 
	return "";
}

function SetCookie(value){ 	var Days = 30; var exp  = new Date(); 	exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = "58home="+ escape (value) + ";domain=.58.com;expires=" + exp.toGMTString(); }

function clickGo()
{
    var key =encodeURI(document.getElementById('keyword').value);
    window.location = "http://q.58.com/"+key;
}

var D0_ggad_str ="";
var D2_ggad_str ="";
function WriteDetail(){
	if(window.location.href.indexOf("huochepiao")>0)
	{
		document.write('<iframe src="http://pic2.58.com/7days.html" width="100%" height="200" frameborder="0" scrolling="no"></iframe>');		
	}
	else
	{
		if(D2_ggad_str==""){setTimeout(WriteDetail,1000);	}
		else{$('detailad_div').innerHTML = D2_ggad_str;}
	}
}

function writeUserName(){
    if (!(document.cookie != null && document.cookie != '' && document.cookie != 'undefined')) {
        var exp = new Date(); exp.setTime(exp.getTime() + 30 * 24 * 60 * 60 * 1000);
        document.cookie = "supportcookie=true;domain=58.com;expires=" + exp.toGMTString();
        if (!(document.cookie != null && document.cookie != '' && document.cookie != 'undefined')) {
            document.write('<script type="text/javascript" src="http://user.58.com/UserLoginState.ashx"></script>');
            return true;
        }
    }
    var host = window.location.hostname;
    var hosthome = host.substr(0, host.indexOf("."));
    var outurl = window.location.href;
    var str = '<a href="http://www.58.com/fabu/" target="_self">发布信息</a> <a href="http://my.58.com/login/?path=' + outurl + '" target="_self">登录</a> <a href="http://my.58.com/reg/?city=' + hosthome + '" target="_self">注册</a>';
    var str2 = '<a href="http://www.58.com/fabu/" target="_self">发布信息</a> <a href="http://my.58.com/login/?path=' + outurl + '" target="_self">登录</a> <a href="http://my.58.com/reg/?city=' + hosthome + '" target="_self">注册</a>';
    try {
        if (GetCookies("UserName") != "") {
            var msgcount = parseInt(GetCookies("MsgUnReadTotal")) + parseInt(GetCookies("SystemUnReadTotal")) + parseInt(GetCookies("RequireFriendUnReadTotal")) + parseInt(GetCookies("CommentUnReadTotal"));
            str = '<a href="http://my.58.com/' + GetCookies("UserID") + '/">' + GetCookies("UserName") + '</a> <img alt="站内消息" hspace="4" src="http://pic.58.com/images/icoMail.gif" /><a  href="http://my.58.com/Liuyanjieshou/">(' + msgcount + ')</a> <a href="http://my.58.com/" target="_self">用户中心</a> <a href="http://www.58.com/fabu/" target="_self">发布</a> <a href="http://my.58.com/ajax/loginout/?path=' + outurl + '" target="_self">退出</a>';
            str2 = '<a href="http://my.58.com/' + GetCookies("UserID") + '/">' + GetCookies("UserName") + '</a> <img alt="站内消息" hspace="4" src="http://pic.58.com/images/icoMail.gif" /><a  href="http://my.58.com/Liuyanjieshou/">(' + msgcount + ')</a> <a href="http://my.58.com/" target="_self">用户中心</a> <a href="http://www.58.com/fabu/" target="_self">发布</a> <a href="http://my.58.com/ajax/loginout/?path=' + outurl + '" target="_self">退出</a>';
        }
        if (cityc()) { document.write(str2); }
        else { document.write(str); }
        return true;
    }
    catch (e) { document.write(str); return true; }
}

function ieResize()
{
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var ver=parseFloat(b_version);
	if(browser=="Microsoft Internet Explorer"){
		if(ver<6.9){document.body.style.width = (document.documentElement.clientWidth < 1000) ? "1000px" : "auto";}
		else{document.body.style.minWidth ="1000px";}
	}	
}

function opGo(urlstr)
{
	window.location = "http://"+window.location.hostname+urlstr;
}

function recContent(contentid){     var txtcont = "[quote]"+contentid+"[/quote]";     $("txtContent").value=txtcont;} 
function SetupRevert(){	
	var WRevert = "";
	if(GetCookies("UserName") == ""){WRevert="匿名";	}
	else{WRevert="欢迎您:"+GetCookies("UserName")+"&nbsp;&nbsp;&nbsp;&nbsp;<label for=\"chkUser\"><input type=\"checkbox\" name=\"chkUser\" id=\"chkUser\" value=1 />匿名发布</label>";}
	if($("ReverUser")!=null){
	$("ReverUser").innerHTML = WRevert + $("ReverUser").innerHTML;
	}
}

function getText(objname)
{
	var reg=/<div id="?\w[^>]*"?>\w*[^<]*<\/div>/ig;
	return $(objname).innerHTML.replace(reg,"");
}
function InitDiscus()
{
	return true;
}
var changecity={
         mode:"iframe",
         url:"http://pic2.58.com/changecity.htm",
         ot:"",
         createFrame:function()
         {
            if(this.ot=="")
            {
            document.getElementById("all_city").innerHTML='<iframe id="chf" scrolling="no" width="400" height="210" src="'+this.url+'" frameborder="0"></iframe>';
            }
            else
            {
            document.getElementById("all_city").innerHTML='<iframe id="chf" scrolling="no" width="400" height="210" src="'+this.url+"?"+this.ot+'" frameborder="0"></iframe>';
            }
         },
         changeClass:function(className)
         {
            if(className=="sc")
            {
             if(!document.getElementById("chf"))
             {
               this.url="http://www.58.com/ichangecity.aspx";
               this.createFrame();
             }
            }
            document.getElementById('all_city').className=className;
         }
}

function cityc()
{
	var str = window.location.href;
	return false;
}
function getUserMsg()
{	
  return;
		document.write('<div style=" border-bottom:1px solid #f80; background:#FFFFCC; padding:5px; color:#F00; text-align:center">公告：58.com黄页类别改版预计于8月13日上线，在此期间，如影响了您的正常使用，请联系我们，详情请 <a href="http://q.58.com/58TongCheng/Topic_434616.shtml" style=" text-decoration:underline;" target="_blank">点击查看</a></div>');	
	

}
/* old ad*/
var picnum = 0;var pageadstr = "";var adtongstr="";
function setimggo() { var stra = pageadstr.split('|'); document.getElementById('top_ad_pic').innerHTML = stra[picnum]; picnum++; document.getElementById('numtext').innerHTML = picnum + "/" + (stra.length - 1); if (picnum == (stra.length - 1)) { picnum = 0; } }
function goPlay() { var stra = pageadstr.split('|'); if (pageadstr == "") { document.getElementById('top_ad_pic').innerHTML = "<a href='http://biz.58.com' target='_blank'><img src='http://pic2.58.com/images/newcopy/default_newcopy_zs.gif'></a>"; } else { document.getElementById('top_ad_pic').innerHTML = stra[0]; document.getElementById('numtext').innerHTML = parseInt(picnum + 1) + "/" + (stra.length - 1); if (stra.length > 2) {picnum = 1; } var a = setInterval(setimggo, 3000); } }
//bcity_ad_tou
function goPlayTong(){
	if(adtongstr=="")	 return;
	var stra = adtongstr.split('|'); 
	//if(adtongstr=="")	 $('tong_ad').innerHTML = "";	
	if(stra.length==2)  $('tong_ad').innerHTML = stra[0]; 
	else if(stra.length >2){$('tong_ad').innerHTML = stra[0];picnum++; var a = setInterval(setimggo2,3000);}
}
function setimggo2(){ 	var stra = adtongstr.split('|');	$('tong_ad').innerHTML = stra[picnum];	picnum++; 	if(picnum == (stra.length-1)) picnum = 0;}

//window.onload=ieResize;
//window.onresize =ieResize;


function showdiv()//更多服务
{
	if($("downlist")!=null) $('downlist').className='sc';
	if($("downlist")!=null) $('downlist').focus();
}
document.onclick=function()
{
     if($("downlist")!=null) $("downlist").className='hc';
     try{win.closeToolTipWindow();}catch(e){return true;}
}
